package org.yonggan.shop.sql.report

import org.apache.commons.lang.StringUtils
import org.apache.spark.sql.DataFrame
import org.yonggan.shop.constant.ConfigurationManager
import org.yonggan.shop.utils.SparkUtils

object ShopRptPvAndUv {

  def main(args: Array[String]): Unit = {

    val spark = SparkUtils.getSparkSession("商城的PUUV统计数据分析")
    // 文件输出
    val jsonDF: DataFrame = spark.read.json(ConfigurationManager.TASK_INJSON)

    // DSL
    jsonDF.cache()

    // pv
    val pv:Long = jsonDF.count()
    // uv
    val uv = jsonDF.filter(f => {
      f != null && StringUtils.isNotEmpty(f.getAs[String]("openid"))
    }).select("openid").distinct.count()

    println(pv)
    println(uv)

  }

}
